﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Login : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Session["AccountID"].Equals(""))
        {
            Response.Redirect("~/Default.aspx");
        }
        
    }

    protected void btnLogin_Click(object sender, EventArgs e)
    {
        BankServices.BankingServices sv = new BankServices.BankingServices();
        if (txtUserName.Value.Equals("") || txtPassword.Value.Equals(""))
        {
            lblStatus.Text = "UserName And Password are required!";
        }
        else
        {
            int aid;
            if ((aid = sv.Login(txtUserName.Value, txtPassword.Value)) == 0)
            {
                lblStatus.Text = "Username or Password is wrong!";
            }
            else 
            {
                Session["AccountID"] = aid +"";
                Response.Redirect("~/Default.aspx");
                
            }
        }

        
    }
}